#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1


int main() {
    int seed = 1000;
    int numPlayer = 2;
    int r;//, i;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, minion};
    struct gameState G;
	int loopCnt; //how many loops I want to test this over and over
	int theResult, i;
	int handPos = 4;
	int card = minion; 
	int choice1 = 0;
	int choice2 = 0;
	int choice3 = 0;
	int bonus = 0;
	//int numCards;
	int rndNum;
	int expctAct;
	int rndAction;
	int numAct;
	
	#if (NOISY_TEST == 1)
		printf ("TESTING cardEffect, specifically minion:\n");
	#endif
	
	loopCnt = rand() % 999 + 1; //sets it from 1 to 1,000
	
	for(i=0; i<loopCnt; i++) {
		
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
		
		rndNum = rand() % 26 + 4;
		rndAction = rand() % 19 + 1;
		
		*G.handCount = rndNum; //set the number of cards in the hand to random, not just 4
		G.numActions = rndAction; //set the number of actions to random

		theResult = cardEffect(card, choice1, choice2, choice3, &G, handPos, &bonus); //the number of the switch to use 
				
		numAct = G.numActions;
		
		expctAct = rndAction + 1; //Minion adds 1 to the number of actions
		

		#if (NOISY_TEST == 1)
			printf("number of actions = %d, expected = %d\n", numAct, expctAct); //should add 1 to actions.
		
		#endif
			
		assert(numAct == expctAct); //check if the number of actions is correct
						
							
	}	
	
	printf("All tests passed!\n");

    return 0;
}
